<template>
  <header class="hd">
    <div class="hd__left">
      <div v-if="!locate" class="login-btn">
          <el-button type="primary" size="small" round>系统登录</el-button>
      </div>
      <div v-else class="hd__locate">
        <el-icon class="locate__icon">
          <LocationInformation />
        </el-icon>
        <a class="locate__text" href="/">{{ locate }}</a>
      </div>
    </div>
    <div class="hd__center">
      <div class="hd__title">
          新医智疗
      </div>
    </div>
    <div class="hd__right">
      <div class="hd__time">
          {{ time }}
      </div>
    </div>
  </header>
  <router-view></router-view>
</template>

<script setup>
import { ref, onMounted } from 'vue'

const time = ref(null);
const locate = ref('返回首页');

onMounted(() => {
    setInterval(() => {
        time.value = new Date().toLocaleString()
    }, 1000)
})
</script>

<style lang="scss" scoped>
$hd-bg-color: #475165;
$hd-title-color: #fff;
$hd-text-color: #ccc;

.hd {
    background: $hd-bg-color;
    height: 5vh;
    display: flex;
    align-items: center;
    justify-content: space-between;

    &__left {
        width: 10rem;
        font-size: 1rem;
        font-weight: bold;
        color: $hd-title-color;
        margin-left: 2rem;

        .login-btn {
            width: 8rem;
            margin: 0 auto;
        }

        .locate__icon {
            color: $hd-text-color;
            margin-right: 0.5rem;
        }

        .locate__text {
            font-size: 1rem;
            color: $hd-text-color;
            text-decoration: none;
        }
    }

    &__title {
        font-size: 1rem;
        color: $hd-title-color;
        font-weight: bold;
    }

    &__time {
        width: 10rem;
        font-size: 1rem;
        color: $hd-text-color;
        margin-right: 2rem;
    }
}
</style>